// com/school/entities/Student.java
package com.school.entities;

import java.util.ArrayList;
import java.util.List;

public class Student extends Person {
    private List<Course> selectedCourses;

    public Student(String studentId, String name, String gender) {
        super(studentId, name, gender);
        this.selectedCourses = new ArrayList<>();
    }

    public void selectCourse(Course course) {
        selectedCourses.add(course);
        System.out.println(name + " 成功选修 " + course.getCourseName());
    }

    public void dropCourse(Course course) {
        if (selectedCourses.remove(course)) {
            System.out.println(name + " 成功退选 " + course.getCourseName());
        } else {
            System.out.println(name + " 未选修 " + course.getCourseName() + "，退课失败");
        }
    }

    @Override
    public void printWorkSheet() {
        System.out.println("=== " + name + " 的课表 ===");
        if (selectedCourses.isEmpty()) {
            System.out.println("暂未选修任何课程");
            return;
        }
        System.out.println("编号\t课程名称\t上课地点\t时间\t授课教师");
        for (Course course : selectedCourses) {
            System.out.println(course.getCourseId() + "\t" +
                    course.getCourseName() + "\t" +
                    course.getLocation() + "\t" +
                    course.getTime() + "\t" +
                    course.getTeacher().getName());
        }
    }

    public int getSelectedCourseCount() {
        return selectedCourses.size();
    }
}